<template>
      <div id="login-top">
        <div id="ms-login">
            <!--标题-->
            <div id="ms-title">后台管理系统</div>
            <!--用户名-->
            <el-form :model="param" :rules="rules" ref="login" label-width="0px" id="ms-content">
                <el-form-item prop="userName">
                    <el-input v-model="param.userName" placeholder="userName">
                        <el-button slot="prepend" icon="el-icon-lx-people"></el-button>
                    </el-input>
                </el-form-item>
                <!--密码-->
                <el-form-item prop="password">
                    <el-input
                        type="password"
                        placeholder="password"
                        v-model="param.password"
                        @keyup.enter.native="submitForm()">
                        <el-button slot="prepend" icon="el-icon-lx-lock"></el-button>
                    </el-input>
                </el-form-item>
                <!--登录-->
                <div id="login-btn">
                    <el-button type="primary" @click="submitForm()">登录</el-button>
                </div>
                <!--备注-->
                <p id="login-tips">如果登录失败，不要哭，专业写BUG团队！ </p>
            </el-form>
        </div>
        <div class="cube">
        <!-- 外层立方体 -->
        <div class="outer-cube">
            <div class="outer-top">
            <img src="../assets/red.jpg"/>
            </div>
            <div class="outer-bottom">
            <img src="../assets/blue.jpg"/>
            </div>
            <div class="outer-front">
            <img src="../assets/block.jpg"/>
            </div>
            <div class="outer-back">
            <img src="../assets/white.jpg"/>
            </div>
            <div class="outer-left">
            <img src="../assets/yellow.jpg"/>
            </div>
            <div class="outer-right">
            <img src="../assets/7.jpg"/>
            </div>
        </div>
        <!-- 内层立方体 -->
        <div class="inner-cube">
            <div class="inner-top">
            <img src="../assets/8.jpg"/>
            </div>
            <div class="inner-bottom">
            <img src="../assets/red.jpg"/>
            </div>
            <div class="inner-front">
            <img src="../assets/blue.jpg"/>
            </div>
            <div class="inner-back">
            <img src="../assets/block.jpg"/>
            </div>
            <div class="inner-left">
            <img src="../assets/yellow.jpg"/>
            </div>
            <div class="inner-right">
            <img src="../assets/7.jpg"/>
            </div>
        </div>
        </div>
    </div>
</template>

<script>
export default {
    data: function() {
        return {
            param: {
                userName: '',
                password: '',
            },
            rules: {
                userName: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
                password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
            },
        };
    },
    methods:{
        submitForm(){
                var _this=this;
                //清空本地存储的token
                localStorage.setItem('token','');
                //用户登录
                _this.$http.get(
                    //地址
                    "/api/sso/userLogin/authUser?userName="+_this.param.userName+
                    "&passWord="+_this.param.password
                ).then(function (response) {
                    console.log("登录回调。。。。"+JSON.stringify(response.data))
                    if (response.data.code==2000) {
                        _this.$message.success("登录成功！");
                        localStorage.setItem('ms_username', _this.param.userName);
                        console.log(_this.param.userName);
                        localStorage.setItem('token',response.data.data.accessToken);
                        localStorage.setItem('userId',response.data.data.user.userId);
                        localStorage.setItem('userName',response.data.data.user.userName);
                        localStorage.setItem('loginName',response.data.data.user.loginName);
                        localStorage.setItem('avatar',response.data.data.user.avatar);
                        _this.$router.push('/tree');
                    } else {
                    _this.$message.error("用户名或者密码错误");
                }
                })
                .catch(function (error) {
                console.log(error);
                _this.$message.error("你错了。。。");
                });
        },
    },
};
</script>

<style>
#login-top {
    position: relative;
    width: 100%;
    height: 700px;
    /* background-color: aqua; */
    background-image: url(../assets/8.jpg); 
    background-size: 100%;
}
#ms-title {
    width: 100%;
    line-height: 50px;
    text-align: center;
    font-size: 20px;
    color: rgb(7, 7, 7);
    border-bottom: 1px solid #ddd;
}
#ms-login {
    position: absolute;
    left: 50%;
    top: 350px;
    width: 350px;
    margin: -190px 0 0 -175px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
}
#ms-content {
    padding: 30px 30px;
}
#login-btn {
    text-align: center;
}
#login-btn button {
    width: 100%;
    height: 36px;
    margin-bottom: 10px;
}
#login-tips {
    font-size: 12px;
    line-height: 30px;
    color: rgb(8, 8, 8);
}
/* //立方体 */
.cube {
    position: relative;
    top: 20%;
    margin: 0px auto;
    /* margin-top: 9%; */
    margin-left: 75%;
    width: 200px;
    height: 200px;
    transform: rotateX(-30deg) rotateY(-80deg);
    transform-style: preserve-3d;
    animation: rotate 15s infinite;
}

.cube .outer-cube,
.cube .inner-cube {
    transform-style: preserve-3d;
}

/* 旋转立方体 */
@keyframes rotate {
    from {
        transform: rotateX(0deg) rotateY(0deg);
    }

    to {
        transform: rotateX(360deg) rotateY(360deg);
    }
}

/* 外层立方体样式 */
.outer-cube .outer-top,
.outer-cube .outer-bottom,
.outer-cube .outer-right,
.outer-cube .outer-left,
.outer-cube .outer-front,
.outer-cube .outer-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    border: 1px solid #fff;
    opacity: 0.3;
    transition: all .9s;
}

.outer-cube img {
    width: 200px;
    height: 200px;
}


.outer-top {
    transform: rotateX(90deg) translateZ(100px);
}

.outer-bottom {
    transform: rotateX(-90deg) translateZ(100px);
}

.outer-front {
    transform: rotateY(0deg) translateZ(100px);
}

.outer-back {
    transform: translateZ(-100px) rotateY(180deg);
}

.outer-left {
    transform: rotateY(90deg) translateZ(100px);
}

.outer-right {
    transform: rotateY(-90deg) translateZ(100px);
}

/* 嵌套的内层立方体样式 */
.inner-cube>div {
    position: absolute;
    top: 35px;
    left: 35px;
    width: 130px;
    height: 130px;
}

.inner-cube img {
    width: 130px;
    height: 130px;
}

.inner-top {
    transform: rotateX(90deg) translateZ(65px);
}

.inner-bottom {
    transform: rotateX(-90deg) translateZ(65px);
}

.inner-front {
    transform: rotateY(0deg) translateZ(65px);
}

.inner-back {
    transform: translateZ(-65px) rotateY(180deg);
}

.inner-left {
    transform: rotateY(90deg) translateZ(65px);
}

.inner-right {
    transform: rotateY(-90deg) translateZ(65px);
}

.cube:hover .outer-top {
    right: -70px;
    bottom: -70px;
    opacity: 0.8;
    transform: rotateX(90deg) translateZ(200px);
}

.cube:hover .outer-bottom {
    right: -70px;
    bottom: -70px;
    opacity: 0.8;
    transform: rotateX(-90deg) translateZ(200px);
}

.cube:hover .outer-front {
    right: -70px;
    bottom: -70px;
    opacity: 0.8;
    transform: rotateY(0deg) translateZ(200px);
}

.cube:hover .outer-back {
    right: -70px;
    bottom: -70px;
    opacity: 0.8;
    transform: translateZ(-200px) rotateY(180deg);
}

.cube:hover .outer-left {
    right: -70px;
    bottom: -70px;
    opacity: 0.8;
    transform: rotateY(90deg) translateZ(200px);
}

.cube:hover .outer-right {
    right: -70px;
    bottom: -70px;
    opacity: 0.8;
    transform: rotateY(-90deg) translateZ(200px);
}

.message .author {
    position: absolute;
    right: 50px;
    background-image: -webkit-linear-gradient(left, blue, #66ffff 10%, #cc00ff 20%, #CC00CC 30%, #CCCCFF 40%, #00FFFF 50%, #CCCCFF 60%, #CC00CC 70%, #CC00FF 80%, #66FFFF 90%, blue 100%);
    font-size: 35px;
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    -webkit-background-size: 200% 100%;
    -webkit-animation: masked-animation 4s linear infinite;
}

@keyframes masked-animation {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: -100% 0;
    }
}

.message .tip {
    position: absolute;
    right: 0px;
    margin-top: 60px;
    color: red;
    font-size: 18px;
}
</style>